using System;
using System.Threading;
using System.Threading.Tasks;
using Matrix.Notification.Domain.Notifications;
using NotificationEntity = Matrix.Notification.Domain.Notifications.Notification;

namespace Matrix.Notification.Channels
{
    /// <summary>
    /// 通知通道接口（简化版本）
    /// </summary>
    public interface INotificationChannel
    {
        /// <summary>
        /// 通道类型
        /// </summary>
        string ChannelType { get; }

        /// <summary>
        /// 检查通道是否可用
        /// </summary>
        Task<bool> IsAvailableAsync(CancellationToken cancellationToken = default);

        /// <summary>
        /// 发送单个通知
        /// </summary>
        Task<NotificationChannelResult> SendAsync(
            object notification,
            CancellationToken cancellationToken = default);

        /// <summary>
        /// 批量发送通知
        /// </summary>
        Task<NotificationChannelResult> SendBatchAsync(
            IReadOnlyCollection<object> notifications,
            CancellationToken cancellationToken = default);
    }

    /// <summary>
    /// 通知通道发送结果
    /// </summary>
    public class NotificationChannelResult
    {
        /// <summary>
        /// 是否成功
        /// </summary>
        public bool IsSuccess { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string? ErrorMessage { get; set; }

        /// <summary>
        /// 发送时间
        /// </summary>
        public DateTime SentAt { get; set; } = DateTime.UtcNow;

        /// <summary>
        /// 成功数量
        /// </summary>
        public int SuccessCount { get; set; }

        /// <summary>
        /// 失败数量
        /// </summary>
        public int FailureCount { get; set; }

        /// <summary>
        /// 消息ID（邮件等返回的唯一标识）
        /// </summary>
        public string? MessageId { get; set; }
    }
}